package com.hyst.web;
import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import com.hyst.common.ResultBean;
import com.hyst.domain.AdminLog;
import com.hyst.service.AdminLogService;
/**
 *@Description:用户日志表controller
 *@author：Administrator
 *@Date：2018年04月17日
*/
@RestController
@RequestMapping("adminLogs")
@CrossOrigin(maxAge=3600,origins="*")
public  class  AdminLogController{
	@Autowired
	private AdminLogService adminLogService;

	@PostMapping
	public ResultBean<AdminLog> creat(AdminLog adminLog) {
		return ResultBean.success(adminLogService.insert(adminLog));
	}
	/**
	 * @Description: 根据主键查询
	 * @param id
	 * @return ResultBean<AdminLog>
	 */
	@GetMapping("{id}")
	public ResultBean<AdminLog> getByPriKey(@PathVariable("id") Integer id) {
		return ResultBean.success(adminLogService.getByPriKey(id));
	}
	/**
	* @Description: 根据主键更新全字段
	* @param adminLog
	* @return ResultBean<AdminLog>
	*/
	@PatchMapping("{id}")
	public ResultBean<AdminLog> update(AdminLog adminLog) {
		return ResultBean.success(adminLogService.update(adminLog));
	}
	/**
	 * @Description: 根据主键更新不为默认值的字段
	 * @param adminLog
	 * @return ResultBean<AdminLog>
	 */
	@PutMapping("{id}")
	public ResultBean<AdminLog> updatePatch (@PathVariable("id") Integer id, AdminLog adminLog) {
		return ResultBean.success(adminLogService.updateSelective(adminLog));
	}
		/**
	* @Description: 根据主键删除
	* @param id
	* @return ResultBean<AdminLog>
	*/
	@DeleteMapping("{id}")
	public ResultBean<AdminLog> delete(@PathVariable("id") Integer id) {
		return ResultBean.success(adminLogService.delete(id));
	}
	
	

}